
<%@ page import="com.capgemini.rdlgae.domain.Facture"%>
<%@ page import="com.capgemini.rdlgae.domain.Commande"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:set var="entityName"
	value="${message(code: 'facture.label', default: 'Facture')}" />
<title><g:message code="default.create.label"
	args="[entityName]" /></title>
</head>
<body>
<div class="nav"><span class="menuButton"><g:link
	class="list" action="list">
	<g:message code="default.list.label" args="[entityName]" />
</g:link></span></div>
<div class="body">
<h1><g:message code="default.create.label" args="[entityName]" /></h1>
<g:if test="${flash.message}">
	<div class="message">
	${flash.message}
	</div>
</g:if> <g:hasErrors bean="${factureInstance}">
	<div class="errors"><g:renderErrors bean="${factureInstance}"
		as="list" /></div>
</g:hasErrors> <g:form action="save" method="post">
	<div class="dialog">
	<table>
		<tbody>

			<tr class="prop">
				<td valign="top" class="name"><label for="dateEdition"><g:message
					code="facture.dateEdition.label" default="Date Edition" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: factureInstance, field: 'dateEdition', 'errors')}">
				<g:datePicker name="dateEdition" precision="day"
					value="${factureInstance?.dateEdition}" /></td>
			</tr>
			<tr class="prop">
				<td valign="top" class="name"><label for="commandes"><g:message
					code="facture.commandes.label" default="Commandes" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: factureInstance, field: 'commandes', 'errors')}">
				
				<div class="list">
				<table>
					<thead>
						<tr>
							<th>Date de commande</th>
							<th>Total</th>
						</tr>
					</thead>
					<tbody>
						<g:each in="${factureInstance.commandes}" status="i"
							var="commande">

							<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
								<td><g:formatDate date="${commande.dateCommande}"
									format="EEEE d MMMM" /></td>
								<td>
								${fieldValue(bean: commande, field: "total")} €
								</td>
							</tr>
						</g:each>
					</tbody>
				</table>
				</div>

				</td>
			</tr>
			<tr class="prop">
				<td valign="top" class="name"><label for="total"><g:message
					code="facture.total.label" default="Total" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: factureInstance, field: 'total', 'errors')}">
					<g:hiddenField name="total" value="${fieldValue(bean: factureInstance, field: 'total')}"/>
					<strong>${fieldValue(bean: factureInstance, field: "total")} €</strong>
				</td>
			</tr>
		</tbody>
	</table>
	</div>
	<div class="buttons"><span class="button"><g:submitButton
		name="create" class="save"
		value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
	</div>
</g:form></div>
</body>
</html>
